package com.qd.common.panda.domain.entity.hk;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.qd.common.panda.util.PlateColorUtil;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author sjk
 */
@Data
@Accessors(chain = true)
public class HkArrearsRecordsDataReq {
    @NotBlank(message = "code不能为空")
    private String code;
    @Valid
    private List<HkArrearsRecords> data;
    /**
     * 1线上支付2钱包支付
     */
    private Integer wallet;

    @Data
    @Accessors(chain = true)
    public static class HkArrearsRecords{
        /**
         * 停车场编号
         */
        @NotBlank(message = "停车场编号不能为空")
        private String parkCode;
        /**
         * 停车场名称
         */
        private String parkName;
        /**
         * 车牌号码
         */
        @NotBlank(message = "车牌号码不能为空")
        private String plateNo;
        /**
         * 车牌颜色
         */
        private Integer plateColor;
        /**
         * 账单总额
         */
        private Integer totalFee;
        /**
         * 欠费金额
         */
        @NotNull(message = "欠费金额不能为空")
        @Min(value = 1, message = "欠费金额必须大于0")
        private Integer arrearsFee;
        /**
         * 欠费时间
         */
        @NotNull(message = "欠费时间不能为空")
        private Long arrearsTime;
        /**
         * 泊位编号
         */
        private String berthCode;
        /**
         * 账单编号
         */
        @NotBlank(message = "账单编号不能为空")
        private String billCode;
        /**
         * 入场唯一ID
         */
        @NotBlank(message = "入场唯一ID不能为空")
        @JsonProperty("inUnid")
        private String inUnid;

        public Integer getPlateColor() {
            if(null !=plateColor){
                plateColor = PlateColorUtil.hkToPanda(plateColor);
            }
            return plateColor;
        }
        public void freeData() {
            this.parkCode = null;
            this.parkName = null;
            this.plateNo = null;
            this.plateColor = null;
            this.totalFee = null;
            this.arrearsFee = null;
            this.arrearsTime = null;
            this.berthCode = null;
            this.billCode = null;
            this.inUnid = null;
        }
    }
}
